package com.atguigu.yygh.task.scheduledtask;



import com.atguigu.yygh.consts.MqConst;
import com.atguigu.yygh.serice.RabbitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author A
 * @version 1.0
 * @description: TODO
 * @date 2025/4/3 1:27
 */

@Component
public class ScheduledTask {
    @Autowired
    private RabbitService rabbitService;
    //@Scheduled(cron = "0/20 * * * * ?") //每20秒执行一次
    @Scheduled(cron = "9 0 8 * * *?")   //每天8点9分执行一次
    public void task1(){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println("task1: " + sdf.format(new Date()));
        rabbitService.sendMesssage(MqConst.EXCHANGE_DIRECT_TASK,MqConst.ROUTING_TASK_8,"xxx");
    }

}
